$(document).ready(function() {
	
	$("#regForm").validate({
		rules:{
				login:{required:true,minlength: 6, maxlength: 20},
				password:{required:true,minlength: 6,maxlength: 20},
				passwordRepeat:{required:true,equalTo: "#password"},
				firstName:{required:true, maxlength: 20},
				lastName:{required:true, maxlength: 20}
		},
	
		messages:{
			login:{
				required:"Enter your login",
				maxlength:"Login is too long",
			password:{
				required:"Enter your password",
				minlength:"Password must be minimum 6 characters",
				maxlength:"Password can not be more than 20 symbols large"},
			passwordRepeat:{
				required:"Enter confirm password",
				equalTo:"Password and Repeat Password must match"},
			firstName:{
				required:"First name can not be empty",
				maxlength:"Too long first name"},
			lastName:{
				required:"Last name can not be empty",
				maxlength:"Too long last name"}	
		},
	
		errorClass: "help-inline",
		errorElement: "span",
		
		highlight:function(element, errorClass, validClass) {
			$(element).parents('.control-group').addClass('error');
			$(element).parents('.control-group').removeClass('success');
		},
		unhighlight: function(element, errorClass, validClass) {
			$(element).parents('.control-group').removeClass('error');
			$(element).parents('.control-group').addClass('success');
		}
	}});
});

